﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="show_check.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.Class.show_check" %>

<%@ Import Namespace="DataAccess" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<body>
    <%
        int cls = int.Parse(Request.QueryString["cls"]);

        DateTime date = DateTime.Parse(Request.QueryString["date"]);
        int shift = int.Parse(Request.QueryString["shift"]);
        var class_check_in = new TblCheckUserController().FetchAll().Where(x => DateTime.Parse(x.DateX.ToString()).Date == date.Date && x.Shifts == shift).ToList();
        
        if (class_check_in.Count != 0)
        {
            var get_student_check = new TblUserController().FetchAll().Where(x => x.ClassX == cls);
            foreach (TblUser std in get_student_check)
            {
    %>
    <li class="check_in_student w3-padding w3-row">
        <img src="../Content/avatar/<%=std.Avatar%>" class="student-img w3-left w3-circle" />
        <div class="check_student_id w3-hide"><%=std.UserId%></div>
        <div class="w3-col l4 w3-padding-top">
            <span><%=std.FullName%></span>
        </div>
        <%
                var student_check = new TblCheckUserController().FetchAll().Where(x => x.UserId == std.UserId && DateTime.Parse(x.DateX.ToString()).Date == date.Date && x.Shifts == shift).ToList();
                if (student_check.Count != 0)
                {
        %>
        <div class="w3-col l7 w3-small">
            <div class="radio w3-row">
                <%if (student_check[0].Early == true)
                  {%>
                <input type="radio" checked="checked" name="diemdanh<%=std.UserId%>" value="1" id="dunggio<%=std.UserId%>" /><label for="dunggio<%=std.UserId%>">Đúng giờ</label>
                <%}
                  else
                  { %>
                <input type="radio"  name="diemdanh<%=std.UserId%>" value="1" id="dunggio<%=std.UserId%>" /><label for="dunggio<%=std.UserId%>">Đúng giờ</label>
                <%} %>
                <%if (student_check[0].Late == true)
                  {%>
                <input type="radio" checked="checked" name="diemdanh<%=std.UserId%>" value="2" id="ditre<%=std.UserId%>" /><label for="ditre<%=std.UserId%>">Đi trễ/Về sớm</label>
                <%}
                  else
                  { %>
                <input type="radio" name="diemdanh<%=std.UserId%>" value="2" id="ditre<%=std.UserId%>" /><label for="ditre<%=std.UserId%>">Đi trễ/Về sớm</label>
                <%} %>
                <%if (student_check[0].AbsentYes == true)
                  { %>
                <input type="radio" checked="checked" name="diemdanh<%=std.UserId%>" value="3" id="vangcophep<%=std.UserId%>" /><label for="vangcophep<%=std.UserId%>">Vắng có phép</label>
                <%}
                  else
                  { %>
                <input type="radio" name="diemdanh<%=std.UserId%>" value="3" id="vangcophep<%=std.UserId%>" /><label for="vangcophep<%=std.UserId%>">Vắng có phép</label>
                <%} %>
                <%if (student_check[0].AbsentNo == true)
                  {%>
                <input type="radio" name="diemdanh<%=std.UserId%>" checked="checked" value="4" id="vangkophep<%=std.UserId%>" /><label for="vangkophep<%=std.UserId%>">Vắng không phép</label>
                <%}
                  else
                  { %>
                <input type="radio" name="diemdanh<%=std.UserId%>" value="4" id="vangkophep<%=std.UserId%>" /><label for="vangkophep<%=std.UserId%>">Vắng không phép</label>
                <%} %>
            </div>
        </div>
        <%}
                else
                { %>
        <div class="w3-col l7 w3-small">
            <div class="radio w3-row">
                <input type="radio" name="diemdanh<%=std.UserId%>" value="1" id="dunggio<%=std.UserId%>" /><label for="dunggio<%=std.UserId%>">Đúng giờ</label>
                <input type="radio" name="diemdanh<%=std.UserId%>" value="2" id="ditre<%=std.UserId%>" /><label for="ditre<%=std.UserId%>">Đi trễ/Về sớm</label>
                <input type="radio" name="diemdanh<%=std.UserId%>" value="3" id="vangcophep<%=std.UserId%>" /><label for="vangcophep<%=std.UserId%>">Vắng có phép</label>
                <input type="radio" name="diemdanh<%=std.UserId%>" value="4" id="vangkophep<%=std.UserId%>" /><label for="vangkophep<%=std.UserId%>">Vắng không phép</label>
            </div>
        </div>
        <%} %>
    </li>
    <%}
        }
        else
        {
            var get_student = new TblUserController().FetchAll().Where(x => x.ClassX == cls);
            foreach (TblUser std in get_student)
            {
    %>
    <li class="check_in_student w3-padding w3-row">
        <img src="../Content/avatar/<%=std.Avatar%>" class="student-img w3-left w3-circle" />
        <div class="check_student_id w3-hide"><%=std.UserId%></div>
        <div class="w3-col l4 w3-padding-top">
            <span><%=std.FullName%></span>
        </div>
        <div class="w3-col l7 w3-small">
            <div class="radio w3-row">

                <input type="radio" name="diemdanh<%=std.UserId%>" value="1" id="dunggio<%=std.UserId%>" /><label for="dunggio<%=std.UserId%>">Đúng giờ</label>

                <input type="radio" name="diemdanh<%=std.UserId%>" value="2" id="ditre<%=std.UserId%>" /><label for="ditre<%=std.UserId%>">Đi trễ/Về sớm</label>

                <input type="radio" name="diemdanh<%=std.UserId%>" value="3" id="vangcophep<%=std.UserId%>" /><label for="vangcophep<%=std.UserId%>">Vắng có phép</label>

                <input type="radio" name="diemdanh<%=std.UserId%>" value="4" id="vangkophep<%=std.UserId%>" /><label for="vangkophep<%=std.UserId%>">Vắng không phép</label>
            </div>
        </div>
    </li>
    <%}
        } %>
</body>
</html>
